Task management method and device

ABSTRACT

A task management method and device where the method includes determining, according to a foreground task, a first scenario corresponding to the foreground task, searching for at least one background task corresponding to the first scenario when the first scenario corresponding to the foreground task is in a first list, where the first list includes a scenario in which task limitation is allowed, and performing limitation processing on the at least one background task corresponding to the first scenario, where the limitation processing refers to processing for reducing system resource usage.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. patent application Ser. No.15/102,459 filed on Jun. 7, 2016, which is a National Stage ofInternational Application No. PCT/CN2014/093028 filed on Dec. 4, 2014,which claims priority to Chinese Patent Application No. 201310665434.9filed on Dec. 10, 2013. All of the aforementioned applications arehereby incorporated by reference in their entireties.

TECHNICAL FIELD

The present disclosure relates to the communications field, and inparticular, to a task management method and device.

BACKGROUND

With development of communications technologies, currently many devicessupport a multi-task system, that is, a device may run multipleapplication programs at the same time, and one application program mayhave one or more threads, each of which is referred to as a task.Multiple tasks usually include a foreground task and a background task.The foreground task refers to a task that requires user interaction,that is, an operation input by a user needs to be received duringexecution of the foreground task. The background task refers to a taskthat does not require user interaction, that is, an operation input by auser does not need to be received during execution of the backgroundtask. Because the background task does not require user interaction, thebackground task is generally not a user-sensitive task, or thebackground task is not of user concern. In other words, some backgroundtasks do not need to be executed. However, the background tasks arecontinually executed in the background of a system, and continuouslyconsume power of a device. It can be seen that, currently a device maysuffer from great power consumption and power loss.

SUMMARY

Embodiments of the present disclosure provide a task management methodand device, to reduce power consumption and power loss of a device.

According to a first aspect, an embodiment of the present disclosureprovides a task management method, including determining, according to aforeground task, a first scenario corresponding to the foreground task,searching for, when the first scenario corresponding to the foregroundtask is in a first list, at least one background task corresponding tothe first scenario, where the first list includes a scenario in whichtask limitation is allowed, and performing limitation processing on theat least one background task corresponding to the first scenario, wherethe limitation processing refers to processing for reducing systemresource usage.

In a first possible implementation manner of the first aspect, themethod further includes searching for a second scenario except the firstscenario corresponding to the foreground task, where the second scenariocorresponds to at least one background task, and the first list includesthe second scenario, and performing the limitation processing on the atleast one background task corresponding to the second scenario.

With reference to the first aspect or the first possible implementationmanner of the first aspect, in a second possible implementation mannerof the first aspect, after determining, according to a foreground task,a first scenario corresponding to the foreground task, the methodfurther includes determining whether the first scenario is in the firstlist.

With reference to the first aspect, in a third possible implementationmanner of the first aspect, before performing limitation processing onthe at least one background task corresponding to the first scenario,the method further includes querying a user identifier of the at leastone background task, ignoring the at least one background task if theuser identifier of the at least one background task corresponds to asystem user, performing the limitation processing on the at least onebackground task if the user identifier of the at least one backgroundtask corresponds to a common user.

With reference to the first aspect, in a fourth possible implementationmanner of the first aspect, before performing limitation processing onthe at least one background task corresponding to the first scenario,the method further includes starting a timer for the at least onebackground task corresponding to the first scenario, and stopping asystem component used by the at least one background task correspondingto the first scenario when the timer exceeds a preset threshold.

With reference to the first aspect, in a fifth possible implementationmanner of the first aspect, before performing limitation processing onthe at least one background task corresponding to the first scenario,the method further includes querying whether the at least one backgroundtask uses a system component, and stopping the system component if theat least one background task uses the system component.

With reference to the first aspect, the first possible implementationmanner of the first aspect, the second possible implementation manner ofthe first aspect, the third possible implementation manner of the firstaspect, the fourth possible implementation manner of the first aspect,or the fifth possible implementation manner of the first aspect, in asixth possible implementation manner of the first aspect, processing forreducing system resource usage includes at least one of the followingmanners freezing the at least one background task, stopping the at leastone background task, and limiting a system resource used by the at leastone background task.

With reference to the first aspect, the first possible implementationmanner of the first aspect, the second possible implementation manner ofthe first aspect, the third possible implementation manner of the firstaspect, the fourth possible implementation manner of the first aspect,or the fifth possible implementation manner of the first aspect, in aseventh possible implementation manner of the first aspect, determining,according to a foreground task, a first scenario corresponding to theforeground task includes determining, according to at least oneforeground task, a first scenario corresponding to each foreground task.

According to a second aspect, an embodiment of the present disclosureprovides a task management method, including determining, according to aforeground task, a first scenario corresponding to the foreground task,determining a second scenario except the first scenario corresponding tothe foreground task, where the second scenario is a scenario in whichtask limitation is allowed and the second scenario corresponds to atleast one background task, searching for the at least one backgroundtask corresponding to the second scenario, and performing limitationprocessing on the at least one background task corresponding to thesecond scenario, where the limitation processing refers to processingfor reducing system resource usage.

In a first possible implementation manner of the second aspect, themethod further includes searching for at least one background taskcorresponding to the first scenario, and performing the limitationprocessing on the at least one background task corresponding to thefirst scenario if a user identifier of the at least one background taskcorresponding to the first scenario corresponds to a common user.

With reference to the second aspect, in a second possible implementationmanner of the second aspect, before performing limitation processing onthe at least one background task corresponding to the second scenario,the method further includes starting a timer for the at least onebackground task corresponding to the second scenario, and stopping asystem component used by the at least one background task correspondingto the second scenario, when the timer exceeds a preset threshold.

With reference to the second aspect, in a third possible implementationmanner of the second aspect, before performing limitation processing onthe at least one background task corresponding to the second scenario,the method further includes querying whether the at least one backgroundtask uses a system component, and stopping the system component if theat least one background task uses the system component.

With reference to the second aspect, the first possible implementationmanner of the second aspect, the second possible implementation mannerof the second aspect, or the third possible implementation manner of thesecond aspect, in a fourth possible implementation manner of the secondaspect, processing for reducing system resource usage includes at leastone of the following manners: freezing the at least one background task,stopping the at least one background task, and limiting a systemresource used by the at least one background task.

With reference to the second aspect, the first possible implementationmanner of the second aspect, the second possible implementation mannerof the second aspect, or the third possible implementation manner of thesecond aspect, in a fifth possible implementation manner of the secondaspect, determining, according to a foreground task, a first scenariocorresponding to the foreground task includes determining, according toat least one foreground task, a first scenario corresponding to eachforeground task.

According to a third aspect, an embodiment of the present disclosureprovides a task management method, including a determining unit, a firstsearch unit, and a first processing unit, where the determining unit isconfigured to determine, according to a foreground task, a firstscenario corresponding to the foreground task. The first search unit isconfigured to search for, when the first scenario that corresponds tothe foreground task and is determined by the determining unit is in afirst list, at least one background task corresponding to the firstscenario, where the first list includes a scenario in which tasklimitation is allowed, and the first processing unit is configured toperform limitation processing on the at least one background task thatcorresponds to the first scenario and is searched for by the firstsearch unit, where the limitation processing refers to processing forreducing system resource usage.

In a first possible implementation manner of the third aspect, thedevice further includes a second search unit configured to search for asecond scenario except the first scenario that corresponds to theforeground task and is searched for by the determining unit, where thesecond scenario corresponds to at least one background task, and thefirst list includes the second scenario, and a second processing unitconfigured to perform the limitation processing on the at least onebackground task that corresponds to the second scenario and is searchedfor by the second search unit.

With reference to the third aspect or the first possible implementationmanner of the third aspect, in a second possible implementation mannerof the third aspect, the device further includes a judging unitconfigured to determine whether the first scenario is in the first list.

With reference to the third aspect, in a third possible implementationmanner of the third aspect, the device further includes a first queryunit configured to query a user identifier of the at least onebackground task, and an ignoring unit configured to ignore the at leastone background task if the user identifier that is of the at least onebackground task and queried by the first query unit corresponds to asystem user, where the first processing unit is configured to performthe limitation processing on the at least one background task if theuser identifier that is of the at least one background task and queriedby the first query unit corresponds to a common user.

With reference to the third aspect, in a fourth possible implementationmanner of the third aspect, the device further includes a timing unitconfigured to start a timer for the at least one background taskcorresponding to the first scenario, and a first stopping unitconfigured to stop, when the timer exceeds a preset threshold, a systemcomponent used by the at least one background task corresponding to thefirst scenario.

With reference to the third aspect, in a fifth possible implementationmanner of the third aspect, the device further includes a second queryunit configured to query whether the at least one background task uses asystem component, and a second stopping unit configured to stop thesystem component if the second query unit finds that the at least onebackground task uses the system component.

With reference to the third aspect, the first possible implementationmanner of the third aspect, the second possible implementation manner ofthe third aspect, the third possible implementation manner of the thirdaspect, the fourth possible implementation manner of the third aspect,or the fifth possible implementation manner of the third aspect, in asixth possible implementation manner of the third aspect, the processingfor reducing system resource usage includes at least one of thefollowing manners: freezing the at least one background task, stoppingthe at least one background task, and limiting a system resource used bythe at least one background task.

With reference to the third aspect, the first possible implementationmanner of the third aspect, the second possible implementation manner ofthe third aspect, the third possible implementation manner of the thirdaspect, the fourth possible implementation manner of the third aspect,or the fifth possible implementation manner of the third aspect, in aseventh possible implementation manner of the third aspect, thedetermining unit is configured to determine, according to at least oneforeground task, a first scenario corresponding to each foreground task.

According to a second aspect, an embodiment of the present disclosureprovides a task management method, including a first determining unit, asecond determining unit, a first search unit, and a first processingunit, where the first determining unit is configured to determine,according to a foreground task, a first scenario corresponding to theforeground task. The second determining unit is configured to determinea second scenario except the first scenario that corresponds to theforeground task and is determined by the first determining unit, wherethe second scenario is a scenario in which task limitation is allowedand the second scenario corresponds to at least one background task. Thefirst search unit is configured to search for the at least onebackground task corresponding to the second scenario that is determinedby the second determining unit, and the first processing unit isconfigured to perform limitation processing on the at least onebackground task that corresponds to the second scenario and is searchedfor by the first search unit, where the limitation processing refers toprocessing for reducing system resource usage.

In a first possible implementation manner of the second aspect, thedevice further includes a second search unit configured to search for atleast one background task corresponding to the first scenario, and asecond processing unit configured to perform the limitation processingon the at least one background task corresponding to the first scenarioif a user identifier of the at least one background task correspondingto the first scenario corresponds to a common user.

With reference to the second aspect, in a second possible implementationmanner of the second aspect, the device further includes a timing unitconfigured to start a timer for the at least one background taskcorresponding to the second scenario, and a first stopping unitconfigured to stop, when the timer exceeds a preset threshold, a systemcomponent used by the at least one background task corresponding to thesecond scenario.

With reference to the second aspect, in a third possible implementationmanner of the second aspect, the device further includes a query unitconfigured to query whether the at least one background task uses asystem component, and a second stopping unit configured to stop thesystem component if the query unit finds that the at least onebackground task uses the system component.

With reference to the second aspect, the first possible implementationmanner of the second aspect, the second possible implementation mannerof the second aspect, or the third possible implementation manner of thesecond aspect, in a fourth possible implementation manner of the secondaspect, the processing for reducing system resource usage includes atleast one of the following manners: freezing the at least one backgroundtask, stopping the at least one background task, and limiting a systemresource used by the at least one background task.

With reference to the second aspect, the first possible implementationmanner of the second aspect, the second possible implementation mannerof the second aspect, or the third possible implementation manner of thesecond aspect, in a fifth possible implementation manner of the secondaspect, the determining unit is configured to determine, according to atleast one foreground task, a first scenario corresponding to eachforeground task.

In the foregoing technical solutions, a first scenario corresponding toa foreground task is determined according to the foreground task, andwhen the first scenario corresponding to the foreground task is in afirst list, at least one background task corresponding to the firstscenario is searched for, where the first list includes a scenario inwhich task limitation is allowed, and limitation processing is performedon the at least one background task corresponding to the first scenario,where the limitation processing refers to processing for reducing systemresource usage. In this way, limitation processing is implemented on atleast one background task corresponding to a scenario in which tasklimitation is allowed. Compared with the prior art in which a backgroundtask is always being executed, the embodiments of the present disclosurecan reduce power consumption and power loss of a device.

BRIEF DESCRIPTION OF DRAWINGS

To describe the technical solutions in the embodiments of the presentdisclosure or in the prior art more clearly, the following brieflyintroduces the accompanying drawings required for describing theembodiments or the prior art. The accompanying drawings in the followingdescription show merely some embodiments of the present disclosure, anda person of ordinary skill in the art may still derive other drawingsfrom these accompanying drawings without creative efforts.

FIG. 1 is a schematic flowchart of a task management method according toan embodiment of the present disclosure;

FIG. 2 is a schematic flowchart of another task management methodaccording to an embodiment of the present disclosure;

FIG. 3 is a schematic flowchart of another task management methodaccording to an embodiment of the present disclosure;

FIG. 4 is a schematic flowchart of another task management methodaccording to an embodiment of the present disclosure;

FIG. 5 is a schematic flowchart of another task management methodaccording to an embodiment of the present disclosure;

FIG. 6 is a schematic flowchart of another task management methodaccording to an embodiment of the present disclosure;

FIG. 7 is a schematic diagram of another task management methodaccording to an embodiment of the present disclosure;

FIG. 8 is a schematic diagram of a structure of a task management deviceaccording to an embodiment of the present disclosure;

FIG. 9 is a schematic diagram of a structure of another task managementdevice according to an embodiment of the present disclosure;

FIG. 10 is a schematic diagram of a structure of another task managementdevice according to an embodiment of the present disclosure;

FIG. 11 is a schematic diagram of a structure of another task managementdevice according to an embodiment of the present disclosure;

FIG. 12 is a schematic diagram of a structure of another task managementdevice according to an embodiment of the present disclosure;

FIG. 13 is a schematic diagram of a structure of another task managementdevice according to an embodiment of the present disclosure;

FIG. 14 is a schematic diagram of a structure of another task managementdevice according to an embodiment of the present disclosure;

FIG. 15 is a schematic diagram of a structure of another task managementdevice according to an embodiment of the present disclosure;

FIG. 16 is a schematic diagram of a structure of another task managementdevice according to an embodiment of the present disclosure;

FIG. 17 is a schematic diagram of a structure of another task managementdevice according to an embodiment of the present disclosure;

FIG. 18 is a schematic diagram of a structure of another task managementdevice according to an embodiment of the present disclosure; and

FIG. 19 is a schematic diagram of a structure of another task managementdevice according to an embodiment of the present disclosure.

DESCRIPTION OF EMBODIMENTS

The following clearly and completely describes the technical solutionsin the embodiments of the present disclosure with reference to theaccompanying drawings in the embodiments of the present disclosure. Thedescribed embodiments are merely some but not all of the embodiments ofthe present disclosure. All other embodiments obtained by a person ofordinary skill in the art based on the embodiments of the presentdisclosure without creative efforts shall fall within the protectionscope of the present disclosure.

In the embodiments of the present disclosure, a first scenario and asecond scenario are not limited to two scenarios. The first scenario mayindicate one or more scenarios, and the second scenario may alsoindicate one or more scenarios. For example, the first scenario may be ascenario corresponding to a foreground task, and there may be one ormore foreground tasks at the same time, that is, the first scenario maybe one or more scenarios. The second scenario may be any one or morescenarios except the first scenario. For example, the second scenariomay be a scenario corresponding to a task excluding a foreground task.Here, the first and the second are named only for distinguishing twodifferent scenarios.

In addition, in the embodiments of the present disclosure, a scenariomay refer to a status of an action of a device that implements theembodiments of the present disclosure. The status of the action of thedevice may refer to a status in which the device uses a system resource.The system resource may be a hardware resource, such as a centralprocessing unit (CPU) resource or a memory resource, or the systemresource may be a virtual resource, such as a network bandwidth resourceor an operating system resource, which is not limited in the embodimentsof the present disclosure. A scenario may be making a call, sending ashort message service message, using a browser, playing a twodimensional (2D)/three dimensional (3D) game, viewing a main userinterface, downloading a file, reading an electronic book (e-book),playing music, watching a video, navigating through a website, browsinga photo, taking a photo, making a video, sending an email, and the like.

In addition, in the embodiments of the present disclosure, a scenariocorresponding to a task may be a scenario that a task enters when thetask is executed. For example, when a music task is being executed, thetask enters a music scenario and a download scenario, that is, ascenario corresponding to the music task may include the music scenarioand the download scenario. In addition, a task corresponding to ascenario may be a task that enters the scenario. For example, when amusic task is being executed, the task enters a download scenario. Whena browser task is being executed, the task also enters the downloadscenario. When a software update task is being executed, the task alsoenters the download scenario. In this way, the tasks corresponding tothe download scenario may include the music task, the browser task, andthe software update task, that is, one scenario corresponds to differenttasks.

In addition, in the embodiments of the present disclosure, a foregroundtask may refer to a task that requires user interaction, that is, anoperation input by a user needs to be received during execution of theforeground task. Alternatively, a foreground task may refer to a taskthat is displayed on a screen. A background task may refer to a taskthat does not require user interaction during execution, that is, anoperation input by a user does not need to be received during executionof the background task. Alternatively, a background task may refer to atask that is not displayed on a screen. In addition, it can beunderstood that a task may be a thread in the embodiments of the presentdisclosure.

Referring to FIG. 1, FIG. 1 is a schematic flowchart of a taskmanagement method according to an embodiment of the present disclosure.As shown in FIG. 1, the method includes the following steps.

Step 101: Determine, according to a foreground task, a first scenariocorresponding to the foreground task.

Optionally, step 101 may be determining, when a current task isswitched, a corresponding first scenario according to the current task.For example, when the current task, a music task, is being executed, thetask enters a music scenario or a download scenario. In this way, it canbe determined that the first scenario corresponding to the foregroundtask may be the music scenario, the download scenario, or the like. Inaddition, the foreground task may be one or multiple foreground tasks.In the case of multiple foreground tasks, step 101 may includedetermining, according to multiple foreground tasks, a first scenariocorresponding to each foreground task. That is, step 101 may includedetermining, according to at least one foreground task, a first scenariocorresponding to each foreground task.

Step 102: When the first scenario corresponding to the foreground taskis in a first list, search for at least one background taskcorresponding to the first scenario, where the first list includes ascenario in which task limitation is allowed.

Optionally, the scenario in which task limitation is allowed and that isincluded in the first list may be a scenario that is set for receivingan operation input by a user. In this way, the scenario in which tasklimitation is allowed, and that is set according to the operation inputby the user and meets the user's requirements or habits can beimplemented. For example, a user likes to reduce power consumption of adevice, and the user may set in the first list multiple scenarios inwhich task limitation is allowed, for example, setting a browserscenario, a game scenario, a navigation scenario, or the like as thescenario in which task limitation is allowed. In this way, when thefirst scenario corresponding to the current task is the browserscenario, the game scenario, or the navigation scenario, step 102 can beperformed to reduce power consumption of the device.

Optionally, the scenario in which task limitation is allowed and that isincluded in the first list may be automatically set according toperformance of a device. For example, when the device has betterperformance, for example, a CPU of the device is running at a highspeed, the device has a larger memory, or the device has enough battery,only a few scenarios in which task limitation is allowed may be set inthe first list. For example, when the device has poor performance, forexample, the CPU of the device is running at a low speed, the device hasa smaller memory, or the device does not have enough battery, morescenarios in which task limitation is allowed may be set in the firstlist. Because the first list has more scenarios in which task limitationis allowed, and step 102 and step 103 are performed multiple times,limitation processing can be performed on multiple background tasks inorder to reduce power consumption of the device and ensure stablerunning of the device.

Optionally, the at least one background task corresponding to the firstscenario may refer to at least one background task in all backgroundtasks corresponding to the first scenario, or the at least onebackground task corresponding to the first scenario may refer to allbackground tasks corresponding to the first scenario. This embodimentsets no limit thereto.

Step 103: Perform limitation processing on the at least one backgroundtask corresponding to the first scenario, where the limitationprocessing refers to processing for reducing system resource usage.

Optionally, the limitation processing may be processing for reducing asystem resource currently used by a task. For example, a quantity ofsystem resources used by a background task A is A when step 101 isperformed, and after the limitation processing is performed on thebackground task A, a quantity of system resources used by the backgroundtask A is B, where A is greater than B. In addition, B may be zero.

Optionally, the method may be further applied to any devices having amulti-task system, such as a tablet computer, a mobile phone, ane-reader, a remote control, a personal computer (PC), a notebookcomputer, an in-vehicle device, a web television (TV), a wearabledevice, or other intelligent devices having a network function.

In the foregoing technical solutions, a first scenario corresponding toa foreground task is determined according to the foreground task, andwhen the first scenario corresponding to the foreground task is in afirst list, at least one background task corresponding to the firstscenario is searched for, where the first list includes a scenario inwhich task limitation is allowed, and limitation processing is performedon the at least one background task corresponding to the first scenario,where the limitation processing refers to processing for reducing systemresource usage. In this way, limitation processing is implemented on atleast one background task corresponding to a scenario in which tasklimitation is allowed. Compared with the prior art in which a backgroundtask is always being executed, this embodiment of the present disclosurecan reduce power consumption and power loss of a device.

Referring to FIG. 2, FIG. 2 is a schematic flowchart of another taskmanagement method according to an embodiment of the present disclosure.As shown in FIG. 2, the method includes the following steps.

Step 201: Determine, according to a foreground task, a first scenariocorresponding to the foreground task.

Step 202: Determine whether the first scenario is in a first list. Ifyes, perform step 203. If no, end the process. The first list includes ascenario in which task limitation is allowed.

Step 203: Search for at least one background task corresponding to thefirst scenario.

Optionally, step 203 may be further searching for at least onebackground task that is in background tasks corresponding to the firstscenario and that will not affect other tasks or an operating systemafter undergoing limitation processing, or searching for at least onepre-determined background task in background tasks corresponding to thefirst scenario, or searching for at least one background task that is inbackground tasks corresponding to the first scenario and whose useridentifier corresponds to a common user. For example, step 203 mayinclude searching for a user identifier of each background taskcorresponding to the first scenario, and searching for a background taskwhose user identifier (UID) corresponds to a common user as the at leastone background task corresponding to the first scenario.

That is, this step is used to implement that the at least one backgroundtask that is corresponding to the first scenario and is searched for instep 203 is the background task whose UID corresponds to a common user.A UID is an inherent identifier of each task and is used to uniquelyidentify the task. In addition, a UID may correspond to a system userand a common user. When a UID of a background task corresponds to asystem user, it indicates that the background task is a background taskincluded in an operating system. When a UID of a background taskcorresponds to a common user, it indicates that the background task isnot a background task included in an operating system.

Optionally, the method may further include ignoring a background taskwhose UID corresponds to a system user in the at least one backgroundtask corresponding to the first scenario. That is, processing is notperformed on the background task whose UID corresponds to a system user.

Optionally, step 203 may be searching for at least one background taskthat is in background tasks corresponding to the first scenario andwhose system resource usage reaches a preset threshold. For example,searching for at least one background task that is in the backgroundtasks corresponding to the first scenario and whose CPU resource usagereaches 10% of CPU resources, or searching for at least one backgroundtask that is in the background tasks corresponding to the first scenarioand whose sleep lock holding duration reaches 10 minutes, or searchingfor at least one background task that is in the background taskscorresponding to the first scenario and whose average data downloadspeed reaches 10 million (M) per minute.

Step 204: Perform limitation processing on the at least one backgroundtask corresponding to the first scenario, where the limitationprocessing refers to processing for reducing system resource usage.

Optionally, as shown in FIG. 3, the method may further include thefollowing steps.

Step 205: Search for a second scenario except the first scenariocorresponding to the foreground task, where the second scenariocorresponds to at least one background task, and the first list includesthe second scenario.

Step 206: Perform the limitation processing on the at least onebackground task corresponding to the second scenario.

Optionally, the second scenario may refer to one or more scenarios. Inaddition, the second scenario may refer to all scenarios except thefirst scenario, or one or more scenarios except the first scenario,which is not limited in this embodiment.

In addition, the at least one background task corresponding to thesecond scenario may refer to at least one background task in allbackground tasks corresponding to the second scenario, or the at leastone background task corresponding to the second scenario may refer toall background tasks corresponding to the second scenario. Thisembodiment sets no limit thereto. In addition, the second scenario maybe a pre-determined scenario, for example, a scenario that is set forreceiving an operation input by a user. In this way, the scenario inwhich task limitation is allowed, and that is set according to theoperation input by the user and meets the user's requirements or habitscan be implemented. In addition, step 205 may be searching for at leastone background task that is in the background tasks corresponding to thesecond scenario and will not affect other tasks or an operating systemafter undergoing limitation processing, or searching for at least onepre-determined background task in the background tasks corresponding tothe second scenario, or searching for at least one background task thatis in the background tasks corresponding to the second scenario andwhose user identifier corresponds to a common user.

Optionally, the second scenario may be a scenario except the firstscenario and not in a second list, where the second list may include ascenario in which task limitation is prohibited. The scenario in whichtask limitation is prohibited may be a scenario that is set forreceiving an operation input by a user. In this way, the scenario inwhich task limitation is prohibited, and that is set according to theoperation input by the user and meets the user's requirements or habitscan be implemented. For example, the user may set, in the second list, ascenario that requires user attention as the scenario in which tasklimitation is prohibited, for example, a short message service messagescenario, a call scenario, and a download scenario. Alternatively, thescenario in which task limitation is prohibited may be automatically setaccording to performance of a device. For example, when the device hasbetter performance, for example, a CPU of the device is running at ahigh speed, the device has a larger memory, or the device has enoughbattery, more scenarios in which task limitation is prohibited may beset in the second list. For example, when the device has poorperformance, for example, the CPU of the device is running at a lowspeed, the device has a smaller memory, or the device does not haveenough battery, only a few scenarios in which task limitation isprohibited may be set in the second list.

Optionally, before step 204, the method may further include querying aUID of the at least one background task corresponding to the firstscenario, ignoring the at least one background task if the UID of the atleast one background task corresponding to the first scenariocorresponds to a system user, and performing the limitation processingon the at least one background task if the UID of the at least onebackground task corresponds to a common user. That is, step 204 isperforming the limitation processing on the at least one background taskwhose UID corresponds to a common user.

In this implementation manner, because the background task whose UIDcorresponds to a common user is not a task of an operating system, othertasks are not affected after limitation processing is performed on thebackground task Therefore, limitation processing is performed only on abackground task whose UID corresponds to a common user in step 204,which can reduce power consumption and power loss of the device withoutaffecting other tasks.

Optionally, before step 204, the method may further include starting atimer for the at least one background task corresponding to the firstscenario, and stopping, when the timer exceeds a preset threshold, asystem component used by the at least one background task correspondingto the first scenario.

Optionally, the system component includes but is not limited to a timer,a sleep lock, and broadcast notification. Meanwhile, a status value ofthe system component when the system component is paused may be saved inthe foregoing step such that the background task can call the savedstatus value of the system component after the limitation processing isreleased. In addition, the system component used by the at least onebackground task corresponding to the first scenario is stopped only whenthe timer reaches the preset threshold (for example, 10 second (s), 30s, or the like). This may avoid frequently stopping the system componentused by the at least one background task corresponding to the firstscenario.

Optionally, before step 204, the method may further include queryingwhether the at least one background task corresponding to the firstscenario uses a system component, and stopping the system component ifthe at least one background task corresponding to the first scenariouses the system component.

In this implementation manner, because the system component used by theat least one background task corresponding to the first scenario isstopped, power consumption and power loss of the device may also bereduced.

Optionally, the processing for reducing system resource usage mayinclude at least one of the following manners: freezing the at least onebackground task, stopping the at least one background task, and limitinga system resource used by the at least one background task.

In this case, step 204 may be freezing the at least one background taskcorresponding to the first scenario, or stopping the at least onebackground task corresponding to the first scenario, or limiting asystem resource used by the at least one background task correspondingto the first scenario.

Optionally, freezing the at least one background task corresponding tothe first scenario may be prohibiting the background task from calling asystem resource, for example, prohibiting a CPU from calling the atleast one background task corresponding to the first scenario.Furthermore, a task scheduler of an operating system is used to prohibitthe at least one background task corresponding to the first scenariofrom participating in any scheduling. Because the at least onebackground task corresponding to the first scenario is prohibited fromcalling the system resource, power consumption of the device is reduced.

Optionally, limiting a system resource used by the at least onebackground task corresponding to the first scenario may be limiting atime within which the CPU calls the at least one background taskcorresponding to the first scenario. For example, a time value for CPUcalling is set for the at least one background task corresponding to thefirst scenario such that the CPU can call the at least one backgroundtask corresponding to the first scenario within a time indicated by thetime value. In addition, the limiting a system resource used by the atleast one background task corresponding to the first scenario mayfurther be limiting use of the system resource by the at least onebackground task corresponding to the first scenario. For example,limiting use of a network bandwidth by the at least one background taskcorresponding to the first scenario or limiting use of memory space bythe at least one background task corresponding to the first scenario. Inaddition, it may further be using different limitation measuresdepending on different scenarios corresponding to the at least onebackground task corresponding to the first scenario. Because use of thesystem resource by the at least one background task corresponding to thefirst scenario is limited in the foregoing step, power consumption ofthe device is reduced.

Optionally, step 201 may further include determining, according to theforeground task, a first scenario corresponding to the foreground taskwhen a temperature reaches a preset temperature threshold.

The temperature may be a temperature of the device that implements thisembodiment, where the temperature of the device may further refer to atemperature of the CPU of the device or a temperature of a modem of thedevice.

In this implementation manner, it may be implemented that limitationprocessing is performed on the background task only when the temperatureof the device reaches the preset temperature threshold.

Optionally, the method may further include releasing the limitationprocessing on the at least one background task corresponding to thefirst scenario. Furthermore, when the first scenario is not in the firstlist, the limitation processing is released for the background task thathas undergone the limitation processing.

Optionally, the method may be further applied to any devices having amulti-task system, such as a tablet computer, a mobile phone, ane-reader, a remote control, a PC, a notebook computer, an in-vehicledevice, a web TV, a wearable device, or other intelligent devices havinga network function.

In the foregoing technical solution, multiple optional implementationmanners are implemented on the basis of the first embodiment, all ofwhich can reduce power consumption and power loss of a device.

Referring to FIG. 4, FIG. 4 is a schematic flowchart of another taskmanagement method according to an embodiment of the present disclosure.As shown in FIG. 4, the method includes the following steps.

Step 401: Determine, according to a foreground task, a first scenariocorresponding to the foreground task.

Optionally, step 401 may further be determining, when a current task isswitched, a corresponding first scenario according to the current task.For example, when the current task, a music task, is being executed, thetask enters a music scenario or a download scenario. In this way, it canbe determined that the first scenario corresponding to the foregroundtask may be the music scenario or the download scenario, or the like. Inaddition, the foreground task may be one or multiple foreground tasks.In the case of multiple foreground tasks, step 401 may includedetermining, according to multiple foreground tasks, a first scenariocorresponding to each foreground task. That is, step 401 may includedetermining, according to at least one foreground task, a first scenariocorresponding to each foreground task.

Step 402: Determine a second scenario except the first scenariocorresponding to the foreground task, where the second scenario is ascenario in which task limitation is allowed and the second scenariocorresponds to at least one background task.

Optionally, the second scenario may refer to one or more scenarios. Inaddition, the second scenario may refer to all scenarios except thefirst scenario, or one or more scenarios except the first scenario,which is not limited in this embodiment. In addition, the secondscenario may be a pre-determined scenario, for example, a scenario thatis set for receiving an operation input by a user. In this way, thescenario in which task limitation is allowed, and that is set accordingto the operation input by the user and meets the user's requirements orhabits can be implemented.

Optionally, the second scenario may be a scenario except the firstscenario and not in a second list, where the second list may include ascenario in which task limitation is prohibited.

Step 403: Search for the at least one background task corresponding tothe second scenario.

Optionally, the at least one background task corresponding to the secondscenario may refer to at least one background task in all backgroundtasks corresponding to the second scenario, or the at least onebackground task corresponding to the second scenario may refer to allbackground tasks corresponding to the second scenario. In addition, step403 may be searching for at least two background tasks that are in thebackground tasks corresponding to the second scenario and that will notaffect other tasks or an operating system after undergoing limitationprocessing, or searching for at least one pre-determined background taskin the background tasks corresponding to the second scenario, orsearching for at least one background task that is in the backgroundtasks corresponding to the second scenario and whose UID corresponds toa common user. For example, step 403 may include searching for a UID ofeach background task corresponding to the second scenario, and searchingfor a background task whose UID corresponds to a common user as the atleast one background task corresponding to the second scenario.

That is, this step is used to implement that the at least one backgroundtask that is corresponding to the second scenario and is searched for instep 403 is the background task whose UID corresponds to a common user.

Optionally, the method may further include ignoring a background taskwhose UID corresponds to a system user in the at least one backgroundtask corresponding to the second scenario. That is, processing is notperformed on the background task whose UID corresponds to a system user.

Optionally, step 403 may be searching for at least one background taskwhose system resource usage reaches a preset threshold in the backgroundtasks corresponding to the second scenario.

Step 404: Perform limitation processing on the at least one backgroundtask corresponding to the second scenario, where the limitationprocessing refers to processing for reducing system resource usage.

Optionally, as shown in FIG. 5, the method may further include thefollowing steps.

Step 405: Search for at least one background task corresponding to thefirst scenario.

Step 406: If a UID of the at least one background task corresponding tothe first scenario corresponds to a common user, perform the limitationprocessing on the at least one background task corresponding to thefirst scenario.

For this implementation manner of this embodiment, further refer to theimplementation manner in which the limitation processing is performed onthe at least one background task corresponding to the first scenario inthe first and second embodiments, which is not repeatedly describedhere.

Optionally, before step 404, the method may further include starting atimer for the at least one background task corresponding to the secondscenario, and stopping, when the timer exceeds a preset threshold, asystem component used by the at least one background task correspondingto the second scenario.

Optionally, the system component includes but is not limited to a timer,a sleep lock, and broadcast notification. Meanwhile, a status value ofthe system component when the system component is paused may be saved inthe foregoing step such that the background task can call the savedstatus value of the system component after the limitation processing isreleased. In addition, the system component used by the at least onebackground task corresponding to the second scenario is stopped onlywhen the timer reaches the preset threshold (for example, 10 s, 30 s, orthe like). This may avoid frequently stopping the system component usedby the at least one background task corresponding to the secondscenario.

Optionally, before step 404, the method may further include queryingwhether the at least one background task uses a system component, andstopping the system component if the at least one background task usesthe system component.

In this implementation manner, because the system component used by theat least one background task corresponding to the second scenario isstopped, power consumption and power loss of the device may be reduced.

Optionally, the processing for reducing system resource usage includesat least one of the following manners: freezing the at least onebackground task, stopping the at least one background task, and limitinga system resource used by the at least one background task.

In this case, step 404 may be freezing the at least one background taskcorresponding to the second scenario, stopping the at least onebackground task corresponding to the second scenario, or limiting asystem resource used by the at least one background task correspondingto the second scenario.

Optionally, freezing the at least one background task corresponding tothe second scenario may be prohibiting the background task from callinga system resource, for example, prohibiting a CPU from calling the atleast one background task corresponding to the first scenario.Furthermore, a task scheduler of an operating system is used to prohibitthe at least one background task corresponding to the first scenariofrom participating in any scheduling. Because the at least onebackground task corresponding to the second scenario is prohibited fromcalling the system resource, power consumption of the device is reduced.

Optionally, limiting a system resource used by the at least onebackground task corresponding to the second scenario may be limiting atime within which the CPU calls the at least one background taskcorresponding to the second scenario. For example, a time value for CPUcalling is set for the at least one background task corresponding to thesecond scenario such that the CPU can call the at least one backgroundtask corresponding to the second scenario within a time indicated by thetime value. In addition, limiting a system resource used by the at leastone background task corresponding to the second scenario may further belimiting use of the system resource by the at least one background taskcorresponding to the second scenario. For example, limiting use of anetwork bandwidth by the at least one background task corresponding tothe second scenario or limiting use of memory space by the at least onebackground task corresponding to the second scenario. In addition, itmay further be using different limitation measures depending ondifferent scenarios corresponding to the at least one background taskcorresponding to the second scenario. Because use of the system resourceby the at least one background task corresponding to the second scenariois limited in the foregoing step, power consumption of the device isreduced.

Optionally, the method may be further applied to any devices having amulti-task system, such as a tablet computer, a mobile phone, ane-reader, a remote control, a PC, a notebook computer, an in-vehicledevice, a web TV, a wearable device, or other intelligent devices havinga network function.

In the foregoing technical solution, a first scenario corresponding to aforeground task is determined according to the foreground task. A secondscenario except the first scenario corresponding to the foreground taskis determined, where the second scenario is a scenario in which tasklimitation is allowed and the second scenario corresponds to at leastone background task. The at least one background task corresponding tothe second scenario is searched for, and limitation processing isperformed on the at least one background task corresponding to thesecond scenario, where the limitation processing refers to processingfor reducing system resource usage. Therefore, power consumption andpower loss of a device can be reduced.

Referring to FIG. 6, FIG. 6 is a schematic flowchart of a taskmanagement method according to an embodiment of the present disclosure.As shown in FIG. 6, the method includes the following steps.

Step 601: Determine whether a scenario that is currently switched to isa scenario included in a whitelist. If yes, perform step 602. If no, endthe process. The whitelist is a preset list including at least onescenario in which background task limitation is allowed.

Optionally, the foregoing scenario may be a status of an action of adevice that implements step 601. The status of the action of the devicemay refer to a status in which the device uses a system resource. Thesystem resource may be a hardware resource, for example, a CPU resourceor a memory resource, or the system resource may be a virtual resource,for example, a network bandwidth resource or an operating systemresource, which is not limited in the embodiments of the presentdisclosure. A scenario may be making a call, sending a short messageservice message, using a browser, playing a 2D/3D game, viewing a mainuser interface, downloading a file, reading an e-book, playing music,watching a video, navigating through a website, browsing a photo, takinga photo, making a video, sending an electronic mail (e-mail), and thelike. In addition, the scenario that is currently switched to may be oneor more scenarios. In addition, scenario switching may be switchinggenerated by a switching time of a foreground task. For example, when aforeground task is started, one or more scenarios are switched to. Forexample, when a task of making a call is started, the device switches toa scenario of making a call. When a music task is started, the deviceswitches to a music playing scenario and a music download scenario, andwhen a game task is started, the device switches to a game scenario andan Internet access scenario. For example, when a foreground task isstopped, the device switches to one or more scenarios. For example, whena game task is stopped, the device switches from a game scenario to amain user interface scenario.

Optionally, the scenario in which background task limitation is allowedmay be a scenario that is set for receiving an operation input by auser. In this way, the scenario in which background task limitation isallowed, and that is set according to the operation input by the userand meets the user's requirements or habits can be implemented. Forexample, a user likes to reduce power consumption of a device, and theuser may set in the whitelist multiple scenarios in which backgroundtask limitation is allowed, for example, setting a browser scenario, agame scenario, a navigation scenario, or the like as the scenario inwhich background task limitation is allowed. In this way, when a currentscenario of the device is the browser scenario, the game scenario, orthe navigation scenario, step 602 can be performed to reduce powerconsumption of the device.

Optionally, the scenario in which background task limitation is allowedmay be automatically set according to performance of the device. Forexample, when the device has better performance, for example, a CPU ofthe device is running at a high speed, the device has a larger memory,or the device has enough battery, only a few scenarios in whichbackground task limitation is allowed may be set in the whitelist. Forexample, when the device has poor performance, for example, the CPU ofthe device is running at a low speed, the device has a smaller memory,or the device does not have enough battery, more scenarios in whichbackground task limitation is allowed may be set in the whitelist.Because the whitelist has more scenarios in which background tasklimitation is allowed, and step 602 and step 603 are performed multipletimes, limitation processing can be performed on multiple backgroundtasks that allow limitation processing in order to reduce powerconsumption of the device and ensure stable running of the device.

Step 602: Search for a background task that allows limitation processingin currently running background tasks when the scenario that iscurrently switched to is the scenario included in the whitelist, wherethe limitation processing refers to processing for reducing systemresource usage.

Optionally, the background task that allows limitation processing may befurther a background task that will not affect other tasks (such as aforeground task) or an operating system after undergoing the limitationprocessing, or the background task that allows limitation processing maybe a pre-determined background task, or the background task that allowslimitation processing may be a background task that meets a specificcondition.

Optionally, the limitation processing may be an operation used to reducea system resource currently used by a task. For example, a quantity ofsystem resources used by a background task A is A when step 602 isperformed, and after the limitation processing is performed on thebackground task A, a quantity of system resources used by the backgroundtask A is B, where A is greater than B. In addition, B may be zero.

Step 603: Perform the limitation processing on the background task thatallows limitation processing.

Optionally, the method may be applied to any devices having a multi-tasksystem, such as a tablet computer, a mobile phone, an e-reader, a remotecontrol, a PC, a notebook computer, an in-vehicle device, a web TV, awearable device, or other intelligent devices having a network function.

It should be noted that, the scenario in this embodiment may beequivalent to the scenario in the foregoing embodiments. In addition,the whitelist in this embodiment may be the first list in the foregoingembodiments.

In the foregoing technical solution, whether a scenario that iscurrently switched to is a scenario included in a whitelist isdetermined, where the whitelist is a preset list including at least onescenario in which background task limitation is allowed. When it isdetermined that the scenario that is currently switched to is thescenario included in the whitelist, a background task that allowslimitation processing is searched for in currently running backgroundtasks, where the limitation processing refers to processing for reducingsystem resource usage, and the limitation processing is performed on thebackground task that allows limitation processing. In this way,limitation processing is implemented on a background task that allowslimitation processing. Compared with the prior art in which a backgroundtask is always being executed, this embodiment of the present disclosurecan reduce power consumption and power loss of a device.

Referring to FIG. 7, FIG. 7 is a schematic diagram of another taskmanagement method according to an embodiment of the present disclosure.As shown in FIG. 7, the method includes the following steps.

Step 701: Detect that a device enters a game scenario, a browserscenario, or a navigation scenario, where the game scenario, the browserscenario, and the navigation scenario are only examples, and thisembodiment includes but is not limited to these scenarios, for example,may also include an audio playing or video playing scenario.

Step 702: Query and determine a background task that needs to be frozen.

Step 703: Determine whether the background task that needs to be frozenuses a system component. If yes, perform step 704. If no, perform step705. Step 703 may include determining whether the background task thatneeds to be frozen uses a sleep lock, and/or determining whether thebackground task that needs to be frozen uses a timer, and/or determiningwhether the background task that needs to be frozen uses broadcastnotification.

Step 704: Pause the system component, where step 704 may include pausingthe sleep lock if the background task that needs to be frozen uses asleep lock, pausing the timer if the background task that needs to befrozen uses a timer, pausing the broadcast notification if thebackground task that needs to be frozen uses broadcast notification.

Step 705: Freeze the background task that needs to be frozen.

The task management method may further include the following steps.

Step 706: Detect that the device switches to a main user interfacescenario.

Step 707: Query the background task that has been frozen.

Step 708: Resume the system component for the background task that hasbeen frozen, where step 708 may include resuming the sleep lock,resuming the timer, and resuming the broadcast notification.

Step 709: Unfreeze the background task that has been frozen.

The following describes apparatus embodiments of the present disclosure.The apparatus embodiments of the present disclosure are used to executethe methods implemented in the first embodiment to the fifth embodimentof the present disclosure. For ease of description, the followingdescribes only the part related to the embodiments of the presentdisclosure. For specific technology details that are not disclosed,refer to the first embodiment, the second embodiment, the thirdembodiment, the fourth embodiment, and the fifth embodiment of thepresent disclosure.

Referring to FIG. 8, FIG. 8 is a schematic diagram of a structure of atask management device according to an embodiment of the presentdisclosure. As shown in FIG. 8, the task management device includes adetermining unit 81, a first search unit 82, and a first processing unit83.

The determining unit 81 is configured to determine, according to aforeground task, a first scenario corresponding to the foreground task.

Optionally, the determining unit 81 may further determine acorresponding first scenario according to the current task when acurrent task is switched. For example, when the current task, a musictask, is being executed, the task enters a music scenario or a downloadscenario. In this way, it can be determined that the first scenariocorresponding to the foreground task may be the music scenario or thedownload scenario, or the like. In addition, the foreground task may beone or multiple foreground tasks. In the case of multiple foregroundtasks, the determining unit 81 may be configured to determine, accordingto multiple foreground tasks, a first scenario corresponding to eachforeground task. That is, the determining unit 81 may determine,according to at least one foreground task, a first scenariocorresponding to each foreground task.

The first search unit 82 is configured to search for, when the firstscenario that corresponds to the foreground task and is determined bythe determining unit 81 is in a first list, at least one background taskcorresponding to the first scenario, where the first list includes ascenario in which task limitation is allowed.

Optionally, the scenario in which task limitation is allowed and that isincluded in the first list may be a scenario that is set for receivingan operation input by a user. In this way, the scenario in which tasklimitation is allowed, and that is set according to the operation inputby the user and meets the user's requirements or habits can beimplemented. For example, a user likes to reduce power consumption of adevice, and the user may set in the first list multiple scenarios inwhich task limitation is allowed, for example, setting a browserscenario, a game scenario, a navigation scenario, or the like as thescenario in which task limitation is allowed. In this way, when thefirst scenario corresponding to the current task is the browserscenario, the game scenario, or the navigation scenario, the firstsearch unit 82 can perform a search action to reduce power consumptionof the device.

Optionally, the scenario in which task limitation is allowed and that isincluded in the first list may be automatically set according toperformance of a device. For example, when the device has betterperformance, for example, a CPU of the device is running at a highspeed, the device has a larger memory, or the device has enough battery,only a few scenarios in which task limitation is allowed may be set inthe first list. For example, when the device has poor performance, forexample, the CPU of the device is running at a low speed, the device hasa smaller memory, or the device does not have enough battery, morescenarios in which task limitation is allowed may be set in the firstlist. In this way, power consumption of the device can be reduced.

Optionally, the at least one background task corresponding to the firstscenario may refer to at least one background task in all backgroundtasks corresponding to the first scenario, or the at least onebackground task corresponding to the first scenario may refer to allbackground tasks corresponding to the first scenario. This embodimentsets no limit thereto.

The first processing unit 83 is configured to perform limitationprocessing on the at least one background task that corresponds to thefirst scenario and is searched for by the first search unit 82, wherethe limitation processing refers to processing for reducing systemresource usage.

Optionally, the limitation processing may be processing for reducing asystem resource currently used by a task.

Optionally, the device may be any devices having a multi-task system,such as a tablet computer, a mobile phone, an e-reader, a remotecontrol, a PC, a notebook computer, an in-vehicle device, a web TV, awearable device, or other intelligent devices having a network function.

In the foregoing technical solutions, a first scenario corresponding toa foreground task is determined according to the foreground task, andwhen the first scenario corresponding to the foreground task is in afirst list, at least one background task corresponding to the firstscenario is searched for, where the first list includes a scenario inwhich task limitation is allowed, and limitation processing is performedon the at least one background task corresponding to the first scenario,where the limitation processing refers to processing for reducing systemresource usage. In this way, limitation processing is implemented on atleast one background task corresponding to a scenario in which tasklimitation is allowed. Compared with the prior art in which a backgroundtask is always being executed, the embodiments of the present disclosurecan reduce power consumption and power loss of a device.

Referring to FIG. 9, FIG. 9 is a schematic diagram of a structure of atask management device according to an embodiment of the presentdisclosure. As shown in FIG. 9, the task management device includes adetermining unit 91, a judging unit 92, a first search unit 93, and afirst processing unit 94.

The determining unit 91 is configured to determine, according to aforeground task, a first scenario corresponding to the foreground task.

The judging unit 92 is configured to determine whether the firstscenario that is determined by the determining unit 91 is in a firstlist, where the first list includes a scenario in which task limitationis allowed.

The first search unit 93 is configured to search for, when the judgingunit 92 determines that the first scenario that is determined by thedetermining unit 91 is in the first list, at least one background taskcorresponding to the first scenario.

Optionally, the first search unit 93 may further search for at least onebackground task that is in background tasks corresponding to the firstscenario and that will not affect other tasks or an operating systemafter undergoing limitation processing, or search for at least onepre-determined background task in background tasks corresponding to thefirst scenario, or search for at least one background task that is inbackground tasks corresponding to the first scenario and whose useridentifier corresponds to a common user. For example, a UID of eachbackground task corresponding to the first scenario is searched for, anda background task whose UID corresponds to a common user is searched forand used as the at least one background task corresponding to the firstscenario.

In this way, it can be implemented that the at least one background taskthat is corresponding to the first scenario and is searched for by thefirst search unit 93 is the background task whose UID corresponds to acommon user. A UID is an inherent identifier of each task and may beused to uniquely identify the task. In addition, a UID may correspond toa system user and a common user. When a UID of a background taskcorresponds to a system user, it indicates that the background task is abackground task included in an operating system. When a UID of abackground task corresponds to a common user, it indicates that thebackground task is not a background task included in an operatingsystem.

Optionally, the device may be further configured to ignore a backgroundtask that is in the at least one background task corresponding to thefirst scenario and whose UID corresponds to a system user. That is,processing is not performed on the background task whose UID correspondsto a system user.

Optionally, the first search unit 93 may search for at least onebackground task that is in background tasks corresponding to the firstscenario and whose system resource usage reaches a preset threshold. Forexample, at least one background task that is in the background taskscorresponding to the first scenario and whose CPU resource usage reaches10% of CPU resources is searched for, or at least one background taskthat is in the background tasks corresponding to the first scenario andwhose sleep lock holding duration reaches 10 minutes is searched for, orat least one background task that is in the background taskscorresponding to the first scenario and whose average data downloadspeed reaches 10M per minute is searched for.

The first processing unit 94 is configured to perform limitationprocessing on the at least one background task that corresponds to thefirst scenario and is searched for by the first search unit 93, wherethe limitation processing refers to processing for reducing systemresource usage.

Optionally, as shown in FIG. 10, the device may further include a secondsearch unit 95 configured to search for a second scenario except thefirst scenario that corresponds to the foreground task and is searchedfor by the determining unit 91, where the second scenario corresponds toat least one background task, and the first list includes the secondscenario, and a second processing unit 96 configured to perform thelimitation processing on the at least one background task thatcorresponds to the second scenario and is searched for by the secondsearch unit 95.

Optionally, the second scenario may refer to one or more scenarios. Inaddition, the second scenario may refer to all scenarios except thefirst scenario, or one or more scenarios except the first scenario,which is not limited in this embodiment.

In addition, the at least one background task corresponding to thesecond scenario may refer to at least one background task in allbackground tasks corresponding to the second scenario, or the at leastone background task corresponding to the second scenario may refer toall background tasks corresponding to the second scenario. Thisembodiment sets no limit thereto. In addition, the second scenario maybe a pre-determined scenario, for example, a scenario that is set forreceiving an operation input by a user. In this way, the scenario inwhich task limitation is allowed, and that is set according to theoperation input by the user and meets the user's requirements or habitscan be implemented. In addition, the second search unit 95 may furthersearch for at least one background task that is in the background taskscorresponding to the second scenario and will not affect other tasks oran operating system after undergoing limitation processing, or searchfor at least one pre-determined background task in the background taskscorresponding to the second scenario, or search for at least onebackground task that is in the background tasks corresponding to thesecond scenario and whose user identifier corresponds to a common user.

Optionally, the second scenario may be a scenario except the firstscenario and not in a second list, where the second list may include ascenario in which task limitation is prohibited. The scenario in whichtask limitation is prohibited may be a scenario that is set forreceiving an operation input by a user. In this way, the scenario inwhich task limitation is prohibited, and that is set according to theoperation input by the user, and meets the user's requirements or habitscan be implemented. For example, the user may set, in the second list, ascenario that requires user attention as the scenario in which tasklimitation is prohibited, for example, a short message service messagescenario, a call scenario, and a download scenario. Alternatively, thescenario in which task limitation is prohibited may be automatically setaccording to performance of a device. For example, when the device hasbetter performance, for example, a CPU of the device is running at ahigh speed, the device has a larger memory, or the device has enoughbattery, more scenarios in which task limitation is prohibited may beset in the second list. For example, when the device has poorperformance, for example, the CPU of the device is running at a lowspeed, the device has a smaller memory, or the device does not haveenough battery, only a few scenarios in which task limitation isprohibited may be set in the second list.

Optionally, as shown in FIG. 11, the device may further include a firstquery unit 97 configured to query a UID of the at least one backgroundtask, and an ignoring unit 98 configured to ignore the at least onebackground task if the UID that is of the at least one background taskand queried by the first query unit 97 corresponds to a system user,where the first processing unit 94 may be configured to perform thelimitation processing on the at least one background task if the useridentifier that is of the at least one background task and queried bythe first query unit 97 corresponds to a common user.

In this implementation manner, because the background task whose UIDcorresponds to a common user is not a task of an operating system, othertasks are not affected after limitation processing is performed on thesebackground tasks. Therefore, the first processing unit 94 limits only abackground task whose UID corresponds to a common user, which can reducepower consumption and power loss of the device without affecting othertasks.

Optionally, as shown in FIG. 12, the device may further include a timingunit 99 configured to start a timer for the at least one background taskcorresponding to the first scenario, and a first stopping unit 100configured to stop a system component used by the at least onebackground task corresponding to the first scenario when the timerexceeds a preset threshold.

Optionally, the system component includes but is not limited to a timer,a sleep lock, and broadcast notification. In addition, a status value ofthe system component when the system component is paused may be saved inthe device such that the background task can call the saved status valueof the system component after the limitation processing is released. Inaddition, the system component used by the at least one background taskcorresponding to the first scenario is stopped only when the timerreaches the preset threshold (for example, 10 s, 30 s, or the like).This may avoid frequently stopping the system component used by the atleast one background task corresponding to the first scenario.

Optionally, as shown in FIG. 13, the device may further include a secondquery unit 101 configured to query whether the at least one backgroundtask uses a system component, and a second stopping unit 102 configuredto stop the system component if the second query unit 101 finds that theat least one background task uses the system component.

In this implementation manner, because the system component used by theat least one background task corresponding to the first scenario isstopped, power consumption and power loss of the device may be reduced.

Optionally, the processing for reducing system resource usage includesat least one of the following manners: freezing the at least onebackground task, stopping the at least one background task, and limitinga system resource used by the at least one background task.

In this way, the first processing unit 94 may freeze the at least onebackground task corresponding to the first scenario, or stop the atleast one background task corresponding to the first scenario, or limita system resource used by the at least one background task correspondingto the first scenario.

Optionally, freezing the at least one background task corresponding tothe first scenario may be prohibiting the background task from calling asystem resource, for example, prohibiting a CPU from calling the atleast one background task corresponding to the first scenario.Furthermore, a task scheduler of an operating system is used to prohibitthe at least one background task corresponding to the first scenariofrom participating in any scheduling. Because the at least onebackground task corresponding to the first scenario is prohibited fromcalling the system resource, power consumption of the device is reduced.

Optionally, limiting a system resource used by the at least onebackground task corresponding to the first scenario may be limiting atime within which the CPU calls the at least one background taskcorresponding to the first scenario. For example, a time value for CPUcalling is set for the at least one background task corresponding to thefirst scenario such that the CPU can call the at least one backgroundtask corresponding to the first scenario within a time indicated by thetime value. In addition, limiting a system resource used by the at leastone background task corresponding to the first scenario may further belimiting use of the system resource by the at least one background taskcorresponding to the first scenario from using the system resource. Forexample, limiting the at least one background task corresponding to thefirst scenario or limiting use of memory space by the at least onebackground task corresponding to the first scenario. In addition, it mayfurther be using different limitation measures depending on differentscenarios corresponding to the at least one background taskcorresponding to the first scenario. Because use of the system resourceby the at least one background task corresponding to the first scenariois limited in the foregoing step, power consumption of the device isreduced.

Optionally, when a temperature reaches a preset temperature threshold,the determining unit 91 may be further configured to determine,according to the foreground task, a first scenario corresponding to theforeground task.

The temperature may be a temperature of the device, where thetemperature of the device may further refer to a temperature of the CPUof the device or a temperature of a modem of the device.

In this implementation manner, it may be implemented that limitationprocessing is performed on the background task only when the temperatureof the device reaches the preset temperature threshold.

Optionally, the device may be further configured to release thelimitation processing on the at least one background task correspondingto the first scenario. Furthermore, when the first scenario is not inthe first list, the limitation processing is released for the backgroundtask that has undergone the limitation processing.

Optionally, the device may be any devices having a multi-task system,such as a tablet computer, a mobile phone, an e-reader, a remotecontrol, a PC, a notebook computer, an in-vehicle device, a web TV, awearable device, or other intelligent devices having a network function.

In the foregoing technical solution, multiple optional implementationmanners are implemented on the basis of the first embodiment, all ofwhich can reduce power consumption and power loss of a device.

Referring to FIG. 14, FIG. 14 is a schematic diagram of a structure ofanother task management device according to an embodiment of the presentdisclosure. As shown in FIG. 14, the task management device includes afirst determining unit 141, a second determining unit 142, a firstsearch unit 143, and a first processing unit 144.

The first determining unit 141 is configured to determine, according toa foreground task, a first scenario corresponding to the foregroundtask.

Optionally, the first determining unit 141 may determine, when a currenttask is switched, a corresponding first scenario according to thecurrent task. For example, when the current task, a music task, is beingexecuted, the task enters a music scenario or a download scenario. Inthis way, it can be determined that the first scenario corresponding tothe foreground task may be the music scenario or the download scenario,or the like. In addition, the foreground task may be one or multipleforeground tasks. In the case of multiple foreground tasks, the firstdetermining unit 141 may be configured to determine, according tomultiple foreground tasks, a first scenario corresponding to eachforeground task. That is, the first determining unit 141 may beconfigured to determine, according to at least one foreground task, afirst scenario corresponding to each foreground task.

The second determining unit 142 is configured to determine a secondscenario except the first scenario that corresponds to the foregroundtask and is determined by the first determining unit 141, where thesecond scenario is a scenario in which task limitation is allowed andthe second scenario corresponds to at least one background task.

Optionally, the second scenario may refer to one or more scenarios. Inaddition, the second scenario may refer to all scenarios except thefirst scenario, or one or more scenarios except the first scenario,which is not limited in this embodiment. In addition, the secondscenario may be a pre-determined scenario, for example, a scenario thatis set for receiving an operation input by a user. In this way, thescenario in which task limitation is allowed, and that is set accordingto the operation input by the user and meets the user's requirements orhabits can be implemented.

Optionally, the second scenario may be a scenario except the firstscenario and not in a second list, where the second list may include ascenario in which task limitation is prohibited.

The first search unit 143 is configured to search for the at least onebackground task corresponding to the second scenario that is determinedby the second determining unit 142.

Optionally, the at least one background task corresponding to the secondscenario may refer to at least one background task in all backgroundtasks corresponding to the second scenario, or the at least onebackground task corresponding to the second scenario may refer to allbackground tasks corresponding to the second scenario. In addition, thefirst search unit 143 may further search for at least two backgroundtasks that are in the background tasks corresponding to the secondscenario and that will not affect other tasks or an operating systemafter undergoing limitation processing, or search for at least onepre-determined background task in the background tasks corresponding tothe second scenario, or search for at least one background task that isin the background tasks corresponding to the second scenario and whoseUID corresponds to a common user. For example, the first search unit 143may be configured to search for a UID of each background taskcorresponding to the second scenario, and search for a background taskwhose UID corresponds to a common user as the at least one backgroundtask corresponding to the second scenario.

The foregoing operations can implement that the at least one backgroundtask that is corresponding to the second scenario and is searched for bythe first search unit 143 is the background task whose UID correspondsto a common user.

Optionally, the device may be further configured to ignore a backgroundtask whose UID corresponds to a system user in the at least onebackground task corresponding to the second scenario. That is,processing is not performed on the background task whose UID correspondsto a system user.

Optionally, the first search unit 143 may be configured to search for atleast one background task whose system resource usage reaches a presetthreshold in the background tasks corresponding to the second scenario.

The first processing unit 144 is configured to perform limitationprocessing on the at least one background task that corresponds to thesecond scenario and is searched for by the first search unit 143, wherethe limitation processing refers to processing for reducing systemresource usage.

Optionally, as shown in FIG. 15, the device may further include a secondsearch unit 145 configured to search for at least one background taskcorresponding to the first scenario, and a second processing unit 146configured to perform the limitation processing on the at least onebackground task corresponding to the first scenario if a user identifierof the at least one background task corresponding to the first scenariocorresponds to a common user.

Optionally, as shown in FIG. 16, the device may further include a timingunit 147 configured to start a timer for the at least one backgroundtask corresponding to the second scenario, and a first stopping unit 148configured to stop, when the timer exceeds a preset threshold, a systemcomponent used by the at least one background task corresponding to thesecond scenario.

Optionally, the system component includes but is not limited to a timer,a sleep lock, and broadcast notification. Meanwhile, a status value ofthe system component when the system component is paused may be saved inthe foregoing step such that the background task can call the savedstatus value of the system component after the limitation processing isreleased. In addition, the system component used by the at least onebackground task corresponding to the second scenario is stopped onlywhen the timer reaches the preset threshold (for example, 10 s, 30 s, orthe like). This may avoid frequently stopping the system component usedby the at least one background task corresponding to the secondscenario.

Optionally, as shown in FIG. 17, the device may further include a queryunit 149 configured to query whether the at least one background taskuses a system component, and a second stopping unit 150 configured tostop the system component if the query unit finds that the at least onebackground task uses the system component.

In this implementation manner, because the system component used by theat least one background task corresponding to the second scenario isstopped, power consumption and power loss of the device may be reduced.

Optionally, the processing for reducing system resource usage mayinclude at least one of the following manners: freezing the at least onebackground task, stopping the at least one background task, and limitinga system resource used by the at least one background task.

In this case, the first processing unit 144 may freeze the at least onebackground task corresponding to the second scenario, or stop the atleast one background task corresponding to the second scenario, or limita system resource used by the at least one background task correspondingto the second scenario.

Optionally, freezing the at least one background task corresponding tothe second scenario may be prohibiting the background task from callinga system resource, for example, prohibiting a CPU from calling the atleast one background task corresponding to the first scenario. Further,a task scheduler of an operating system is used to prohibit the at leastone background task corresponding to the first scenario fromparticipating in any scheduling. Because the at least one backgroundtask corresponding to the second scenario is prohibited from calling thesystem resource, power consumption of the device is reduced.

Optionally, limiting a system resource used by the at least onebackground task corresponding to the second scenario may be limiting atime within which the CPU calls the at least one background taskcorresponding to the second scenario. For example, a time value for CPUcalling is set for the at least one background task corresponding to thesecond scenario such that the CPU can call the at least one backgroundtask corresponding to the second scenario within a time indicated by thetime value. In addition, limiting a system resource used by the at leastone background task corresponding to the second scenario may further belimiting use of the system resource by the at least one background taskcorresponding to the second scenario. For example, limiting use of anetwork bandwidth by the at least one background task corresponding tothe second scenario or limiting use of memory space by the at least onebackground task corresponding to the second scenario. In addition, itmay further be using different limitation measures depending ondifferent scenarios corresponding to the at least one background taskcorresponding to the second scenario. Because use of the system resourceby the at least one background task corresponding to the second scenariois limited in the foregoing step, power consumption of the device isreduced.

Optionally, the device may be any devices having a multi-task system,such as a tablet computer, a mobile phone, an e-reader, a remotecontrol, a PC, a notebook computer, an in-vehicle device, a web TV, awearable device, or other intelligent devices having a network function.

In the foregoing technical solution, a first scenario corresponding to aforeground task is determined according to the foreground task. A secondscenario except the first scenario corresponding to the foreground taskis determined, where the second scenario is a scenario in which tasklimitation is allowed and the second scenario corresponds to at leastone background task. The at least one background task corresponding tothe second scenario is searched for, and limitation processing isperformed on the at least one background task corresponding to thesecond scenario, where the limitation processing refers to processingfor reducing system resource usage. Therefore, power consumption andpower loss of a device can be reduced.

Referring to FIG. 18, FIG. 18 is a schematic diagram of a structure ofanother task management device according to an embodiment of the presentdisclosure. As shown in FIG. 18, the task management device includes amemory 181 and a processor 182 connected to the memory 181, where thememory 181 is configured to store program code, and the processor 182 isconfigured to invoke a program stored in the memory 181 to perform thefollowing operations: determining, according to a foreground task, afirst scenario corresponding to the foreground task, searching for, whenthe first scenario corresponding to the foreground task is in a firstlist, at least one background task corresponding to the first scenario,where the first list includes a scenario in which task limitation isallowed, and performing limitation processing on the at least onebackground task corresponding to the first scenario, where thelimitation processing refers to processing for reducing system resourceusage.

Optionally, the processor 182 may further determine, when a current taskis switched, a corresponding first scenario according to the currenttask. For example, when the current task, a music task, is beingexecuted, the task enters a music scenario or a download scenario. Inthis way, it can be determined that the first scenario corresponding tothe foreground task may be the music scenario or the download scenario,or the like. In addition, the foreground task may be one or multipleforeground tasks. In the case of multiple foreground tasks, theprocessor 182 may be configured to determine, according to multipleforeground tasks, a first scenario corresponding to each foregroundtask. That is, the processor 182 may determine, according to at leastone foreground task, a first scenario corresponding to each foregroundtask.

Optionally, the scenario in which task limitation is allowed and that isincluded in the first list may be a scenario that is set for receivingan operation input by a user. In this way, the scenario in which tasklimitation is allowed, and that is set according to the operation inputby the user and meets the user's requirements or habits can beimplemented. For example, a user likes to reduce power consumption of adevice, and the user may set in the first list multiple scenarios inwhich task limitation is allowed, for example, setting a browserscenario, a game scenario, a navigation scenario, or the like as thescenario in which task limitation is allowed. In this way, when thefirst scenario corresponding to the current task is the browserscenario, the game scenario, or the navigation scenario, the processor182 may perform a search operation to reduce power consumption of thedevice.

Optionally, the scenario in which task limitation is allowed and that isincluded in the first list may be automatically set according toperformance of a device. For example, when the device has betterperformance, for example, a CPU of the device is running at a highspeed, the device has a larger memory, or the device has enough battery,only a few scenarios in which task limitation is allowed may be set inthe first list. For example, when the device has poor performance, forexample, the CPU of the device is running at a low speed, the device hasa smaller memory, or the device does not have enough battery, morescenarios in which task limitation is allowed may be set in the firstlist because the first list has a large number of scenarios in whichtask limitation is allowed.

Optionally, the at least one background task corresponding to the firstscenario may refer to at least one background task in all backgroundtasks corresponding to the first scenario, or the at least onebackground task corresponding to the first scenario may refer to allbackground tasks corresponding to the first scenario. This embodimentsets no limit thereto.

Optionally, the limitation processing may be processing used to reducecurrent system resource usage.

In another embodiment, the processor 182 may be further configured toperform the following operations: determining, according to a foregroundtask, a first scenario corresponding to the foreground task, determiningwhether the first scenario is in the first list, if yes, searching forat least one background task corresponding to the first scenario,performing limitation processing on the at least one background taskcorresponding to the first scenario, where the limitation processingrefers to processing for reducing system resource usage, and when aresult of the determining is no, ending the process.

Optionally, the processor 182 may further search for at least onebackground task that is in background tasks corresponding to the firstscenario and that will not affect other tasks or an operating systemafter undergoing limitation processing, or search for at least onepre-determined background task in the background tasks corresponding tothe first scenario, or search for at least one background task that isin background tasks corresponding to the first scenario and whose useridentifier corresponds to a common user. For example, the operation,performed by the processor 182, of searching for at least one backgroundtask corresponding to the first scenario may include searching for auser identifier of each background task corresponding to the firstscenario, and searching for a background task whose UID corresponds to acommon user as the at least one background task corresponding to thefirst scenario.

That is, this operation is used to implement that the at least onebackground task that is corresponding to the first scenario and issearched for by the processor 182 is the background task whose UIDcorresponds to a common user. A UID is an inherent identifier of eachtask and is used to uniquely identify the task. In addition, a UID maycorrespond to a system user and a common user. When a UID of abackground task corresponds to a system user, it indicates that thebackground task is a background task included in an operating system.When a UID of a background task corresponds to a common user, itindicates that the background task is not a background task included inan operating system.

Optionally, the processor 182 may be further configured to ignore abackground task whose UID corresponds to a system user in the at leastone background task corresponding to the first scenario. That is,processing is not performed on the background task whose UID correspondsto a system user.

Optionally, the processor 182 may search for at least one backgroundtask that is in background tasks corresponding to the first scenario andwhose system resource usage reaches a preset threshold. For example, atleast one background task that is in the background tasks correspondingto the first scenario and whose CPU resource usage reaches 10% of CPUresources is searched for, or at least one background task that is inthe background tasks corresponding to the first scenario and whose sleeplock holding duration reaches 10 minutes is searched for, or at leastone background task that is in the background tasks corresponding to thefirst scenario and whose average data download speed reaches 10M perminute is searched for.

Optionally, the processor 182 may be further configured to perform theoperations of searching for a second scenario except the first scenariocorresponding to the foreground task, where the second scenariocorresponds to at least one background task, and the first list includesthe second scenario, and performing the limitation processing on the atleast one background task corresponding to the second scenario.

Optionally, the second scenario may refer to one or more scenarios. Inaddition, the second scenario may refer to all scenarios except thefirst scenario, or one or more scenarios except the first scenario,which is not limited in this embodiment.

In addition, the at least one background task corresponding to thesecond scenario may refer to at least one background task in allbackground tasks corresponding to the second scenario, or the at leastone background task corresponding to the second scenario may refer toall background tasks corresponding to the second scenario. Thisembodiment sets no limit thereto. In addition, the second scenario maybe a pre-determined scenario, for example, a scenario that is set forreceiving an operation input by a user. In this way, the scenario inwhich task limitation is allowed, and that is set according to theoperation input by the user and meets the user's requirements or habitscan be implemented. In addition, the processor 182 may further searchfor at least one background task that is in the background taskscorresponding to the second scenario and will not affect other tasks oran operating system after undergoing limitation processing, or searchfor at least one pre-determined background task in the background taskscorresponding to the second scenario, or search for at least onebackground task that is in the background tasks corresponding to thesecond scenario and whose user identifier corresponds to a common user.

Optionally, the second scenario may be a scenario except the firstscenario and not in a second list, where the second list may include ascenario in which task limitation is prohibited. In addition, the secondlist may be referred to as a blacklist. The scenario in which tasklimitation is prohibited may be a scenario that is set for receiving anoperation input by a user. In this way, the scenario in which tasklimitation is prohibited, and that is set according to the operationinput by the user and meets the user's requirements or habits can beimplemented. For example, the user may set, in the second list, ascenario that requires user attention as the scenario in which tasklimitation is prohibited, for example, a short message service messagescenario, a call scenario, and a download scenario. Alternatively, thescenario in which task limitation is prohibited may be automatically setaccording to performance of a device. For example, when the device hasbetter performance, for example, a CPU of the device is running at ahigh speed, the device has a larger memory, or the device has enoughbattery, more scenarios in which task limitation is prohibited may beset in the second list. For example, when the device has poorperformance, for example, the CPU of the device is running at a lowspeed, the device has a smaller memory, or the device does not haveenough battery, only a few scenarios in which task limitation isprohibited may be set in the second list.

Optionally, before the processor 182 performs the operation ofperforming limitation processing on the at least one background taskcorresponding to the first scenario, the processor 182 may be furtherconfigured to perform the operations of querying a UID of the at leastone background task corresponding to the first scenario, and ignoringthe at least one background task if the UID of the at least onebackground task corresponding to the first scenario corresponds to asystem user, or performing the limitation processing on the at least onebackground task if the UID of the at least one background taskcorresponds to a common user. That is, step 204 is performing thelimitation processing on the at least one background task whose UIDcorresponds to a common user.

In this implementation manner, because the background task whose UIDcorresponds to a common user is not a task of an operating system, othertasks are not affected after limitation processing is performed on thesebackground tasks. Therefore, limitation processing is performed only ona background task whose UID corresponds to a common user in step 204,which can reduce power consumption and power loss of the device withoutaffecting other tasks.

Optionally, before the processor 182 performs the operation ofperforming limitation processing on the at least one background taskcorresponding to the first scenario, the processor 182 may be furtherconfigured to perform the operations of starting a timer for the atleast one background task corresponding to the first scenario, andstopping a system component used by the at least one background taskcorresponding to the first scenario when the timer exceeds a presetthreshold.

Optionally, the system component includes but is not limited to a timer,a sleep lock, and broadcast notification. Meanwhile, a status value ofthe system component when the system component is paused may be saved inthe foregoing step such that the background task can call the savedstatus value of the system component after the limitation processing isreleased. In addition, the system component used by the at least onebackground task corresponding to the first scenario is stopped only whenthe timer reaches the preset threshold (for example, 10 s, 30 s, or thelike). This may avoid frequently stopping the system component used bythe at least one background task corresponding to the first scenario.

Optionally, before the processor 182 performs the operation ofperforming limitation processing on the at least one background taskcorresponding to the first scenario, the processor 182 may be furtherconfigured to perform the operations of querying whether the at leastone background task corresponding to the first scenario uses a systemcomponent, and stopping the system component if the at least onebackground task corresponding to the first scenario uses the systemcomponent.

In this implementation manner, because the system component used by theat least one background task corresponding to the first scenario isstopped, power consumption and power loss of the device may be reduced.

Optionally, the processing for reducing system resource usage mayinclude at least one of the following manners: freezing the at least onebackground task, stopping the at least one background task, and limitinga system resource used by the at least one background task.

In this case, the processor 182 may freeze the at least one backgroundtask corresponding to the first scenario, or stop the at least onebackground task corresponding to the first scenario, or limit a systemresource used by the at least one background task corresponding to thefirst scenario.

Optionally, the operation, performed by the processor 182, ofdetermining, according to a foreground task, a first scenariocorresponding to the foreground task may include determining, accordingto the foreground task, a first scenario corresponding to the foregroundtask when a temperature reaches a preset temperature threshold.

The temperature may be a temperature of the device, where thetemperature of the device may further refer to a temperature of the CPUof the device or a temperature of a modem of the device.

In this implementation manner, it may be implemented that limitationprocessing is performed on the background task only when the temperatureof the device reaches the preset temperature threshold.

Optionally, the processor 182 may be further configured to perform theoperation of releasing the limitation processing on the at least onebackground task corresponding to the first scenario. Furthermore thelimitation processing is released for the background task that hasundergone the limitation processing when the first scenario is not inthe first list.

Optionally, the method may be applied to any devices having a multi-tasksystem, such as a tablet computer, a mobile phone, an e-reader, a remotecontrol, a PC, a notebook computer, an in-vehicle device, a web TV, awearable device, or other intelligent devices having a network function.

In the foregoing technical solutions, a first scenario corresponding toa foreground task is determined according to the foreground task, andwhen the first scenario corresponding to the foreground task is in afirst list, at least one background task corresponding to the firstscenario is searched for, where the first list includes a scenario inwhich task limitation is allowed, and limitation processing is performedon the at least one background task corresponding to the first scenario,where the limitation processing refers to processing for reducing systemresource usage. In this way, limitation processing is implemented on atleast one background task corresponding to a scenario in which tasklimitation is allowed. Compared with the prior art in which a backgroundtask is always being executed, this embodiment of the present disclosurecan reduce power consumption and power loss of a device.

Referring to FIG. 19, FIG. 19 is a schematic diagram of a structure ofanother task management device according to an embodiment of the presentdisclosure. As shown in FIG. 19, the task management device includes amemory 191 and a processor 192 connected to the memory 191, where thememory 191 is configured to store program code, and the processor 192 isconfigured to invoke a program stored in the memory 191 to perform theoperations of determining, according to a foreground task, a firstscenario corresponding to the foreground task, determining a secondscenario except the first scenario corresponding to the foreground task,where the second scenario is a scenario in which task limitation isallowed and the second scenario corresponds to at least one backgroundtask, searching for the at least one background task corresponding tothe second scenario, and performing limitation processing on the atleast one background task corresponding to the second scenario, wherethe limitation processing refers to processing for reducing systemresource usage.

Optionally, the processor 192 may further determine, when a current taskis switched, a corresponding first scenario according to the currenttask. For example, when the current task, a music task, is beingexecuted, the task enters a music scenario or a download scenario. Inthis way, it can be determined that the first scenario corresponding tothe foreground task may be the music scenario, the download scenario, orthe like. In addition, the foreground task may be one or multipleforeground tasks. In the case of multiple foreground tasks, theprocessor 192 may be configured to determine, according to multipleforeground tasks, a first scenario corresponding to each foregroundtask. That is, the processor 192 may determine, according to at leastone foreground task, a first scenario corresponding to each foregroundtask.

Optionally, the second scenario may refer to one or more scenarios. Inaddition, the second scenario may refer to all scenarios except thefirst scenario, or one or more scenarios except the first scenario,which is not limited in this embodiment. In addition, the secondscenario may be a pre-determined scenario, for example, a scenario thatis set for receiving an operation input by a user. In this way, thescenario in which task limitation is allowed, and that is set accordingto the operation input by the user and meets the user's requirements orhabits can be implemented.

Optionally, the second scenario may be a scenario except the firstscenario and not in a second list, where the second list may include ascenario in which task limitation is prohibited.

Optionally, the at least one background task corresponding to the secondscenario may refer to at least one background task in all backgroundtasks corresponding to the second scenario, or the at least onebackground task corresponding to the second scenario may refer to allbackground tasks corresponding to the second scenario. In addition, theprocessor 192 may further search for at least two background tasks thatare in the background tasks corresponding to the second scenario andthat will not affect other tasks or an operating system after undergoinglimitation processing, or search for at least one pre-determinedbackground task in the background tasks corresponding to the secondscenario, or search for at least one background task that is in thebackground tasks corresponding to the second scenario and whose UIDcorresponds to a common user. For example, the operation, performed bythe processor 192, of searching for at least one background taskcorresponding to the second scenario may include searching for a UID ofeach background task corresponding to the second scenario, and searchingfor a background task whose UID corresponds to a common user as the atleast one background task corresponding to the second scenario.

That is, this step is used to implement that the at least one backgroundtask that is corresponding to the second scenario and is searched for bythe processor 192 is the background task whose UID corresponds to acommon user.

Optionally, the processor 192 may be further configured to perform theoperation of ignoring a background task whose UID corresponds to asystem user in the at least one background task corresponding to thesecond scenario. That is, processing is not performed on the backgroundtask whose UID corresponds to a system user.

Optionally, the processor 192 may search for at least one backgroundtask whose system resource usage reaches a preset threshold in thebackground tasks corresponding to the second scenario.

Optionally, the processor 192 may be further configured to perform theoperations of searching for at least one background task correspondingto the first scenario, and performing the limitation processing on theat least one background task corresponding to the first scenario if aUID of the at least one background task corresponding to the firstscenario corresponds to a common user.

For this implementation manner of this embodiment, further refer to theimplementation manner in which the limitation processing is performed onthe at least one background task corresponding to the first scenario inthe first and second embodiments, which is not repeatedly describedhere.

Optionally, before the processor 192 performs the operation ofperforming limitation processing on the at least one background taskcorresponding to the second scenario, the processor 192 may be furtherconfigured to perform the operations of starting a timer for the atleast one background task corresponding to the second scenario, andstopping, when the timer exceeds a preset threshold, a system componentused by the at least one background task corresponding to the secondscenario.

Optionally, the system component includes but is not limited to a timer,a sleep lock, and broadcast notification. Meanwhile, a status value ofthe system component when the system component is paused may be saved inthe foregoing step such that the background task can call the savedstatus value of the system component after the limitation processing isreleased. In addition, the system component used by the at least onebackground task corresponding to the second scenario is stopped onlywhen the timer reaches the preset threshold (for example, 10 s, 30 s, orthe like). This may avoid frequently stopping the system component usedby the at least one background task corresponding to the secondscenario.

Optionally, before the processor 192 performs the operation ofperforming limitation processing on the at least one background taskcorresponding to the second scenario, the processor 192 may be furtherconfigured to perform the operations of querying whether the at leastone background task uses a system component, and stopping the systemcomponent if the at least one background task uses the system component.

In this implementation manner, because the system component used by theat least one background task corresponding to the second scenario isstopped, power consumption and power loss of the device may be reduced.

Optionally, processing for reducing system resource usage may include atleast one of the following manners: freezing the at least one backgroundtask, stopping the at least one background task, and limiting a systemresource used by the at least one background task.

In this case, the processor 192 may freeze the at least one backgroundtask corresponding to the second scenario, stop the at least onebackground task corresponding to the second scenario, or limit a systemresource used by the at least one background task corresponding to thesecond scenario.

Optionally, the method may be applied to any devices having a multi-tasksystem, such as a tablet computer, a mobile phone, an e-reader, a remotecontrol, a PC, a notebook computer, an in-vehicle device, a web TV, awearable device, or other intelligent devices having a network function.

In the foregoing technical solution, a first scenario corresponding to aforeground task is determined according to the foreground task. A secondscenario except the first scenario corresponding to the foreground taskis determined, where the second scenario is a scenario in which tasklimitation is allowed and the second scenario corresponds to at leastone background task. The at least one background task corresponding tothe second scenario is searched for, and limitation processing isperformed on the at least one background task corresponding to thesecond scenario, where the limitation processing refers to processingfor reducing system resource usage. Therefore, power consumption andpower loss of a device can be reduced.

A person of ordinary skill in the art may understand that all or some ofthe processes of the methods in the embodiments may be implemented by acomputer program instructing relevant hardware. The program may bestored in a computer-readable storage medium. When the program runs, theprocesses of the methods in the embodiments are performed. The foregoingstorage medium may include a magnetic disc, an optical disc, a read-onlymemory (ROM), or a random access memory (RAM).

What is disclosed above is merely exemplary embodiments of the presentdisclosure, and certainly is not intended to limit the protection scopeof the present disclosure. Therefore, equivalent variations made inaccordance with the claims of the present disclosure shall fall withinthe scope of the present disclosure.

What is claimed is:
 1. A task management method, implemented by anelectronic device, the task management method comprising: executing aforeground task based on an input to the electronic device; determining,according to the foreground task, that a background task limitation isallowed; determining a first background task and a second backgroundtask; performing limitation processing on the first background task,wherein a user identifier of the first background task corresponds to acommon user, wherein the limitation processing comprises at least one offreezing the first background task, stopping the first background task,or limiting a system resource used by the first background task;stopping the first background task from using a system component whenthe first background task uses the system component before performingthe limitation processing on the first background task; and skippinglimitation processing on the second background task, wherein a useridentifier of the second background task corresponds to a system user.2. The task management method of claim 1, wherein performing thelimitation processing on the first background task comprises reducingsystem resource usage of the first background task.
 3. The taskmanagement method of claim 1, wherein determining the first backgroundtask comprises determining the first background task when a systemresource usage of the first background task reaches a preset threshold.4. The task management method of claim 1, wherein determining the secondbackground task comprises determining the second background task when asystem resource usage of the second background task reaches a presetthreshold.
 5. The task management method of claim 1, further comprising:determining, according to the foreground task, a third background task;and performing limitation processing on the third background task. 6.The task management method of claim 1, further comprising saving astatus value of the system component when the system component stopsusing the first background task.
 7. An electronic device, comprising: atleast one processor; and at least one memory coupled to the at least oneprocessor and configured to store computer instructions for execution bythe at least one processor, wherein the computer instructions cause theat least one processor to be configured to: execute a foreground taskbased on an input to the electronic device; determine, according to theforeground task, that a background task limitation is allowed; determinea first background task and a second background task; perform limitationprocessing on the first background task, wherein a user identifier ofthe first background task corresponds to a common user, wherein thelimitation processing comprises at least one of freezing the firstbackground task, stopping the first background task, or limiting asystem resource used by the first background task; stop the firstbackground task from using a system component when the first backgroundtask uses the system component before performing the limitationprocessing on the first background task; and skip limitation processingon the second background task, wherein a user identifier of the secondbackground task corresponds to a system user.
 8. The electronic deviceof claim 7, wherein the computer instructions cause the at least oneprocessor to be configured to perform limitation processing on the firstbackground task by reducing system resource usage of the firstbackground task.
 9. The electronic device of claim 7, wherein thecomputer instructions further cause the at least one processor to beconfigured to determine the first background task when a system resourceusage of the first background task reaches a preset threshold.
 10. Theelectronic device of claim 7, wherein the computer instructions furthercause the at least one processor to be configured to determine thesecond background task when a system resource usage of the secondbackground task reaches a preset threshold.
 11. The electronic device ofclaim 7, wherein the computer instructions further cause the at leastone processor to be configured to: determine, according to theforeground task, a third background task; and perform limitationprocessing on the third background task.
 12. The electronic device ofclaim 7, wherein the computer instructions further cause the at leastone processor to be configured to save a status value of the systemcomponent when the system component stops using the first backgroundtask.
 13. An electronic device, comprising: at least one processor; andat least one memory coupled to the at least one processor and configuredto store computer instructions for execution by the at least oneprocessor, wherein the computer instructions cause the at least oneprocessor to be configured to: allow a background task limitation;determine a background task that needs to be frozen; freeze thebackground task; stop the background task from using a system componentwhen the background task uses the system component before freezing thebackground task; resume the system component when the electronic devicedisplays a main user interface; and unfreeze the background task whenthe electronic device displays the main user interface.
 14. Theelectronic device of claim 13, wherein the background task that needs tobe frozen comprises a background task that is prohibited from calling asystem resource, and wherein the computer instructions further cause theat least one processor to be configured to prohibit the background taskfrom calling the system resource.
 15. The electronic device of claim 13,wherein the computer instructions further cause the at least oneprocessor to be configured to save a status value of the systemcomponent when the system component is stopped.
 16. The task managementmethod of claim 1, wherein the first background task and the secondbackground task correspond to threads of application programs.
 17. Thetask management method of claim 1, wherein the first background task andthe second background task correspond to tasks that do not require userinteraction.
 18. The electronic device of claim 8, wherein the firstbackground task and the second background task correspond to threads ofapplication programs.
 19. The electronic device of claim 7, wherein thefirst background task and the second background task correspond to tasksthat do not require user interaction.
 20. The electronic device of claim13, wherein the background task corresponds to a thread of anapplication program and does not require user interaction.